﻿package mortal.game.view.skill.panel.render
{
    import com.mui.core.*;
    import mortal.common.*;
    import mortal.game.model.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.cd.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.common.tooltip.*;
    import mortal.game.view.skill.*;

    public class SkillItem extends CDItem
    {
        protected var _toolTipMode:int = 1;
        public static const TooltipMode_ShowNext:int = 0;
        public static const TooltipMode_CurOnly:int = 1;
        public static const TooltipMode_GuildSkill:int = 2;

        public function SkillItem()
        {
            return;
        }// end function

        public function get toolTipMode() : int
        {
            return this._toolTipMode;
        }// end function

        public function set toolTipMode(param1:int) : void
        {
            this._toolTipMode = param1;
            return;
        }// end function

        override public function get toolTipData()
        {
            if (_tooltipData is String)
            {
                return _tooltipData;
            }
            if (this._toolTipMode == TooltipMode_CurOnly)
            {
                return dragSource;
            }
            if (this._toolTipMode == TooltipMode_ShowNext)
            {
                _tooltipData = new ToolTipInfo(TooltipType.SkillShowNext, dragSource);
                return _tooltipData;
            }
            if (this._toolTipMode == TooltipMode_GuildSkill)
            {
                _tooltipData = new ToolTipInfo(TooltipType.SkillGuild, dragSource);
                return _tooltipData;
            }
            return _tooltipData;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._toolTipMode = TooltipMode_CurOnly;
            _isShowLeftTimeEffect = false;
            _isShowFreezingEffect = false;
            _isShowToolTip = true;
            isDropAble = false;
            isDragAble = false;
            return;
        }// end function

        public function setBg(param1:String = "shortcutItemBg", param2:int = 6, param3:int = 6) : void
        {
            _paddingTop = param3;
            _paddingLeft = param2;
            if (param1 == null)
            {
                DisplayUtil.removeMe(_bg);
            }
            else
            {
                if (_bg != null)
                {
                    _bg.dispose(true);
                    _bg = null;
                }
                _bg = UIFactory.bg(-1, -1, _width + param2, _height + param3, null, param1);
                _bg.setSize(_width + param2 * 2, _height + param3 * 2);
                this.addChildAt(_bg, 0);
            }
            return;
        }// end function

        override public function setSize(param1:Number, param2:Number) : void
        {
            super.setSize(param1, param2);
            if (_bg != null && _bg.parent != null)
            {
                _bg.setSize(_width + _paddingLeft * 2, _height + _paddingLeft * 2);
            }
            return;
        }// end function

        override protected function resetBitmapSize() : void
        {
            if (_bitmap)
            {
                _bitmap.width = _width - _paddingLeft * 2;
                _bitmap.height = _height - _paddingTop * 2;
            }
            return;
        }// end function

        override protected function updateView() : void
        {
            super.updateView();
            if (_bitmap)
            {
                _bitmap.x = _paddingLeft;
                _bitmap.y = _paddingTop;
            }
            return;
        }// end function

        public function set skillInfo(param1:SkillInfo) : void
        {
            this.setSkillInfo(param1);
            return;
        }// end function

        public function get skillInfo() : SkillInfo
        {
            return dragSource as SkillInfo;
        }// end function

        public function setSkillInfo(param1:SkillInfo) : void
        {
            if (param1 == null)
            {
                super.dragSource = null;
                super.source = null;
                super.updateCDEffect(null, CDDataType.skillInfo);
                return;
            }
            super.dragSource = param1;
            super.source = param1.tSkill.skillIcon + ".jpg";
            super.updateCDEffect(param1, CDDataType.skillInfo);
            return;
        }// end function

        public function setLocked() : void
        {
            super.source = GlobalClass.getBitmap(ImagesConst.Locked);
            super.updateCDEffect(null);
            _isShowLeftTimeEffect = false;
            _isShowFreezingEffect = false;
            super.isShowToolTip = false;
            return;
        }// end function

    }
}
